home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
FTSC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
25KB
|
801 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* This module was written by Bob Hartman */
/* */
/* */
/* BinkleyTerm FTSC Mail Session Routines */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
#define rb_plus "r+b"
int FTSC_callback (char *);
int FTSC_time (long);
int FTSC_sendmail (void);
int FTSC_recvmail (int);
#define NUM_FLAGS 4
void FTSC_sender (int wz)
{
int j;
char junkbuff[128];
long t1;
XON_DISABLE ();
first_block = 0;
if (!wz)
{
first_block = 1;
status_line (MSG_TXT(M_SEND_FALLBACK));
who_is_he = 0;
(void) sprintf (junkbuff, "*%s (%s)",
newnodedes.SystemName,
Full_Addr_Str (&remote_addr));
status_line (junkbuff);
}
Netmail_Session = 1;
(void) FTSC_sendmail ();
t1 = timerset (4500);
/* See what the receiver would like us to do */
while ((!timeup (t1)) && CARRIER)
{
if ((j = PEEKBYTE ()) >= 0)
{
switch (j)
{
case TSYNC:
CLEAR_INBOUND ();
if (FTSC_recvmail (1))
goto get_out;
t1 = timerset (4500);
break;
case SYN:
CLEAR_INBOUND ();
if (on_our_nickel)
(void) SEA_recvreq ();
else
{
SENDBYTE (CAN);
status_line (MSG_TXT(M_REFUSING_IN_FREQ));
}
t1 = timerset (4500);
break;
case ENQ:
CLEAR_INBOUND ();
SEA_sendreq ();
goto get_out;
case NAK:
case 'C':
CLEAR_INBOUND ();
SENDBYTE (EOT);
t1 = timerset (4500);
break;
default:
CLEAR_INBOUND ();
SENDBYTE (SUB);
break;
}
}
else
{
time_release ();
}
}
if (!CARRIER)
{
status_line (MSG_TXT(M_NO_CARRIER));
CLEAR_INBOUND ();
first_block = 0;
return;
}
if (timeup (t1))
{
(void) FTSC_recvmail (1);
status_line (MSG_TXT(M_TOO_LONG));
}
get_out:
first_block = 0;
t1 = timerset (100);
while (!timeup (t1))
time_release ();
if (!wz)
status_line (MSG_TXT(M_0001_END));
}
int FTSC_receiver (int wz)
{
char fname[64];
int havemail, done, np;
unsigned int i;
long t1, t2;
struct stat buf;
char *HoldName;
struct FILEINFO dta;
ADDR tmp;
first_block = 0;
XON_DISABLE ();
if (!wz)
{
first_block = 1;
status_line (MSG_TXT(M_RECV_FALLBACK));
who_is_he = 1;
}
Netmail_Session = 1;
CLEAR_INBOUND ();
/* Save the state of pickup for now */
done = no_pickup;
no_pickup = 0;
if (FTSC_recvmail (0))
{
/* Restore the state of pickup */
no_pickup = done;
if (!wz)
status_line (MSG_TXT(M_0001_END));
first_block = 0;
return (1);
}
/* Restore the state of pickup */
no_pickup = done;
remote_addr = called_addr;
HoldName = HoldAreaNameMunge(&called_addr);
/* Now see if we should send anything back to him */
(void) sprintf (fname, "%s%s.?UT", HoldName, Hex_Addr_Str (&remote_addr));
havemail = !dfind (&dta, fname, 0);
if (!havemail)
{
(void) sprintf (fname, "%s%s.?LO", HoldName, Hex_Addr_Str (&remote_addr));
havemail = !dfind (&dta, fname, 0);
}
if (!havemail)
{
for (np = 0; np <= ALIAS_CNT; np++)
{
if (alias[np].Net == 0)
break;
(void) sprintf (fname, "%s%s.REQ", CURRENT.sc_Inbound, Hex_Addr_Str (&(alias[np])));
havemail = !dfind (&dta, fname, 0);
if (havemail)
break;
}
}
if (!havemail)
{
status_line (MSG_TXT(M_NOTHING_TO_SEND), Full_Addr_Str (&remote_addr));
}
else
{
/* OS/2 likes this */
while (!dfind (&dta, NULL, 1))
;
status_line (MSG_TXT(M_GIVING_MAIL), Full_Addr_Str (&remote_addr));
/* Send the TSYNC's until we get a C or NAK or CAN back */
t1 = timerset (3000); /* set 30 second timeout */
done = 0;
while (!timeup (t1) && CARRIER && !done) /* till then or CD lost */
{
SENDBYTE (TSYNC);
t2 = timerset (300);
while (CARRIER && (!timeup (t2)) && !done)
{
switch (T